﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tradex.Market {

    /// <summary>
    /// The InstrumentInfo class contains the static information that is attached to
    /// an instrument.
    /// </summary>
    [Serializable ()]
    public class InstrumentInfo {

        /// <summary>
        /// Public constructor taking all values.
        /// </summary>
        /// <param name="instrumentType"></param>
        /// <param name="description"></param>
        /// <param name="currency"></param>
        /// <param name="pointValue"></param>
        /// <param name="optionIndicator"></param>
        /// <param name="optionStrikePrice"></param>
        /// <param name="product"></param>
        /// <param name="expiration"></param>
        public InstrumentInfo(
            InstrumentType instrumentType, string description,
            string currency, double pointValue,
            OptionType optionIndicator, double optionStrikePrice,
            string product,
            string expiration
        ) {
            InstrumentType = instrumentType;
            Description = description;
            Currency = currency;
            PointValue = pointValue;
            OptionIndicator = optionIndicator;
            OptionStrikePrice = optionStrikePrice;
            Product = product;
            Expiration = expiration;
        }

        /// <summary>
        /// Gets the InstrumentType.
        /// </summary>
        public InstrumentType InstrumentType { get; private set; }

        /// <summary>
        /// Gets the Description.
        /// </summary>
        public string Description { get; private set; }

        /// <summary>
        /// Gets the currency.
        /// </summary>
        public string Currency { get; private set; }

        /// <summary>
        /// Gets the value of a point (in the currency).
        /// </summary>
        public double PointValue { get; private set; }

        /// <summary>
        /// Gets the option indicator (i.e. whether the insstrument is an option and what type)
        /// </summary>
        public OptionType OptionIndicator { get; private set; }

        /// <summary>
        /// Gets the option strike price.
        /// </summary>
        public double OptionStrikePrice { get; private set; }

        /// <summary>
        /// Gets the instrument's product.
        /// </summary>
        public string Product { get; private set; }

        /// <summary>
        /// Gets the instrument's expiration.
        /// </summary>
        public string Expiration { get; private set; }

        /// <summary>
        /// Compares the content to another InstrumentInfo.
        /// </summary>
        /// <param name="otherItem"></param>
        /// <returns></returns>
        public bool EqualContent(InstrumentInfo otherItem) {
            if (otherItem == null) {
                return false;
            }
            if (
                InstrumentType != otherItem.InstrumentType ||
                Description != otherItem.Description ||
                Currency != otherItem.Currency ||
                PointValue != otherItem.PointValue ||
                OptionIndicator != otherItem.OptionIndicator ||
                OptionStrikePrice != otherItem.OptionStrikePrice ||
                Product != otherItem.Product ||
                Expiration != otherItem.Expiration
            ) {
                return false;
            }
            return true;
        }

        /// <summary>
        /// Checks whether this InstrumentInfo is an update for the InstrumentInfo passed in.
        /// </summary>
        /// <param name="otherItem"></param>
        /// <returns></returns>
        public bool IsUpdate(InstrumentInfo otherItem) {
            if (otherItem == null) {
                return false;
            }
            if (
                InstrumentType != otherItem.InstrumentType ||
                Description != otherItem.Description ||
                Currency != otherItem.Currency ||
                PointValue != otherItem.PointValue ||
                OptionIndicator != otherItem.OptionIndicator ||
                OptionStrikePrice != otherItem.OptionStrikePrice ||
                Product != otherItem.Product ||
                Expiration != otherItem.Expiration
            ) {
                return false;
            }
            return true;
        }

    }

}
